﻿using JT808.Gateway.QueueService.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace JT808.Gateway.QueueService
{
    public class JT808DbContext : DbContext
    {
        public DbSet<TerminalInfo> TerminalInfos { get; set; }
        public DbSet<RegistryInfo> RegistryInfos { get; set; }
        private IConfiguration _configuration;

        public JT808DbContext(IConfiguration configuration)
        {
            _configuration = configuration;
        }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.UseMySql(_configuration.GetConnectionString("DefaultConnection"),
                ServerVersion.AutoDetect(_configuration.GetConnectionString("DefaultConnection")));
            optionsBuilder.UseSnakeCaseNamingConvention();
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
        }
    }
}
